package com.gzsxy.sso.core.model;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.User;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Date;
import java.util.List;

/**
 * @author xiaolong
 * @version 1.0
 * @description: security用户权限模型
 * @date 2021/11/3 13:52
 */
@Getter
@Setter
public class CustomUser extends User implements Serializable {

    private static final long serialVersionUID = 3686140315548457080L;
    private String id;
    /**
     * 用户名
     */
    private String userName;
    /**
     * 真实姓名
     */
    private String realName;
    /**
     * 密码
     */
    private String password;
    /**
     * 身份证
     */
    private String idCard;
    /**
     * 手机号
     */
    private String phone;
    /**
     * 头像
     */
    private String imagePath;
    /**
     * 邮箱
     */
    private String email;
    /**
     * 是否禁用
     */
    private Boolean freeze;

    /**
     * 排序
     */
    private Integer sort;

    /**
     * 更新用户
     */
    private String updateUser;

    /**
     *  添加用户
     */
    private String addUser;
    /**
     * 创建时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;
    /**
     * 更新时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;
    /**
     * 最后一次登录时间
     */
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date lastLoginTime;
    /**
     * 逻辑删除 1（true）已删除， 0（false）未删除
     */
    private Boolean deleted;

    /**
     * 客户端Ip
     */
    private String clientIp;

    /**
     * 角色代码
     */
    private String roleCodes;

    /**
     * 角色id
     */
    private String roleIds;


    /**
     * 是否超级管理员（0否1是）
     */
    private Boolean isSadmin;

    /**
     * 是否系统管理员（0否1是）
     */
    private Boolean isAdmin;

    /**
     * 状态码
     */
    private Integer code;

    /**
     * 返回消息
     */
    private String msg;


    /**
     * 存放当前用户的权限标识
     */
    private List<GrantedAuthority> authorities = new ArrayList<>();



    public CustomUser(String username, String password, Collection<? extends GrantedAuthority> authorities) {
    super(username, password,true,true,true,true, authorities);
  }

  public CustomUser(String username, String password, boolean enabled, boolean accountNonExpired, boolean credentialsNonExpired, boolean accountNonLocked, Collection<? extends GrantedAuthority> authorities) {
    super(username, password, enabled, accountNonExpired, credentialsNonExpired, accountNonLocked, authorities);
  }





}
